package com.sdy.approval.biz.service;

import java.util.Date;
import java.util.List;

import com.sdy.approval.biz.model.TpApproveFlow;
import com.sdy.approval.biz.model.TpApproveFlowConfig;
import com.sdy.approval.biz.model.TpConfigOld;
import com.sdy.approval.biz.param.AddApprovalsParam;
import com.sdy.common.model.BizException;
import com.sdy.mvc.service.BaseService;

/**
 * <p>
 * 审批记录 服务类
 * </p>
 *
 * @author cgj
 * @since 2019-08-09
 */
public interface TpApproveFlowService extends BaseService<TpApproveFlow> {

	/**
	 * 撤回生成的流程
	 * @param applyNum
	 * @param date
	 * @param userId
	 * @return
	 * @throws BizException
	 */
	Boolean withdrawFlows(String applyNum, Date date,  Integer userId) throws BizException;

	/**
	 * 走flow_flowconfig的审批
	 * @param applyNum
	 * @param oneFlow
	 * @param date
	 * @param userId
	 * @return
	 * @throws Exception
	 */
	Integer updateResultByConfig(String applyNum, TpApproveFlow oneFlow, Date date, Integer userId) throws Exception;


	/**
	 * 不走flow_flowconfig的审批
	 * @param applyNum
	 * @param oneFlow
	 * @param date
	 * @param userId
	 * @param deptBaseId
	 * @param roleBaseId
	 * @return
	 * @throws Exception
	 */
	Integer updateResultNotByConfig(String applyNum, TpApproveFlow oneFlow, Date date, Integer userId,Integer deptBaseId,Integer roleBaseId) throws Exception;
	/**
	 * 遗留订单，下架后，该流程需要走流程配置历史的审批
	 * @param applyNum
	 * @param oneFlow
	 * @param date
	 * @param userId
	 * @param configHisNum
	 * @return
	 */
	Integer updateResultByOldConfig(String applyNum, TpApproveFlow oneFlow, Date date, Integer userId, Integer configHisNum) throws Exception;

	/**
	 * 遗留订单，审批时生成新的节点
	 * @param tpConfigOld
	 * @param applyNum
	 * @param date
	 * @param userId
	 * @return
	 * @throws BizException
	 */
	Boolean addNextOldFlow(TpConfigOld tpConfigOld, String applyNum, Date date, Integer userId, Integer historyNum) throws BizException;

	/**
	 * 审批时生成新的节点
	 * @param tpApproveFlowConfig
	 * @param applyNum
	 * @param date
	 * @param userId
	 * @return
	 * @throws BizException
	 */
	Boolean addNextFlow(TpApproveFlowConfig tpApproveFlowConfig, String applyNum, Date date, Integer userId) throws BizException;

	/**
	 * 审批时生成新的节点,不走config
	 * @param tpApproveFlow
	 * @param applyNum
	 * @param date
	 * @param userId
	 * @param deptBaseId
	 * @param roleBaseId
	 * @return
	 * @throws BizException
	 */
	Boolean addNextFlowNotByConfIg(TpApproveFlow tpApproveFlow, String applyNum, Date date, Integer userId,Integer deptBaseId,Integer roleBaseId) throws BizException;


	Boolean insertMany(List<TpApproveFlow> list);
	
	Integer selectMaxEdition(String applyId);

	Boolean addSubNode(String applyId, Integer userId, Integer operType, Date createTime, String resId);

	Boolean addSubNodes(List<AddApprovalsParam> addApprovalsParams, Integer flowAvailable, Integer operType, Date createTime);
}
